<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>User List</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="nivo-slider.css" type="text/css" media="screen" />
</head>
<body>
<div id="bg">
<div id="logo">
<img src="images/logo_and_name.png" alt="" width="305" height="78" />
</div>
<div id="main">
<div id="out"><h3><p align="right"><a href="index3.php">Home</a>&nbsp;&nbsp;|<a href="logout.php">logout</a></p></h3></div>
<!-- header begins -->
<div id="header">	
	
	<div id="slider-wrapper">        
					             <div id="slider" class="nivoSlider">
									<img src="images/header.jpg" alt="" title="" />
									<img src="images/header2.jpg" alt="" title="" />
									<img src="images/header3.jpg" alt="" title="" />
									<img src="images/header4.jpg" alt="" title="" />								
                                   	
		</div>        
      </div>
								
<script type="text/javascript" src="lib/jquery-1.4.3.min.js"></script>
    <script type="text/javascript" src="lib/jquery.nivo.slider.pack.js"></script>
    <script type="text/javascript">
    $(window).load(function() {
        $('#slider').nivoSlider();
    });
    </script>
    
    <?php
if(isset($_GET['userid']))
{
$delete = $_GET['userid'];
echo "<script type=\"text/javascript\">
function show_confirm()
{
var r=confirm(\"Are you sure you want to delete this user?\");
if (r==true)
  {
  document.location.href=\"deleteuser.php?userid=$delete\";
  }

}
</script>";
}
?>

	
</div>
        <div id="buttons">
		<ul>
		<li class="first"><a href="BPLS.php"  title="">Home</a></li>
		<li><a href="BPLS.php" title="Business Permit and Licensing System Module">BPLS</a></li>
		<li><a href="login3.php" title="Real Property Tax Module">RPT</a></li>
			 <li><a href="UserList.php" title="">User List</a></li>
			<li><a href="userverify.php" title="">Verify User</a></li>
		</ul></div>
<!-- header ends -->
<!-- content begins -->
<div id="content_bg">
  <div class="container">
    	
             <?php
    $db_name = "business-is";
	$table_name = "user";

	$user = "root";
	$pass = "";
	
	$connection = mysql_connect("localhost","$user","$pass")
	or die(mysql_error());

	$db = mysql_select_db($db_name, $connection) or die(mysql_error());

	$sql = "SELECT * FROM $table_name order by lastname";

	$result = mysql_query($sql, $connection) or die(mysql_error());

	$contact_list = "<ul>";

	$num= mysql_num_rows($result);
    $m=0;
	$v;
		
	if($num<1)
	{
		$display_block = "<p><em>Empty...</em> </p>";
	}
	else
	{
	
	$number=0;
	while ($row = mysql_fetch_array($result))

	{   
	    echo "<form name=\"forms\" method=\"post\" action=\"\">";
	    if($row['activate']==1)
		{
		$number++;
	    $userid = $row['userid'];
	    $uname = $row['uname'];
		$lastname = $row['lastname'];
		$firstname = $row['firstname'];
		$emailadress = $row['emailadress'];
		//<input name=\"$number\" type=\"checkbox\" value=\"$userid\">
	$contact_list.= "<tr><td>&nbsp;<strong>$lastname,&nbsp; $firstname &nbsp,&nbsp-$emailadress</strong></td><td><a href=\"edituser.php?userid=$userid\">edit</a></td><td><a href=\"?userid=$userid\">delete</a></td></tr>";
     }
	}

	$contact_list .= "</ul>";
	
	echo "<center><table border=\"2\" cellpadding=\"2\" width=\"600\">";
    echo "<tr><td colspan=\"4\" align=\"center\" background=\"images/img5 - Copy - Copy.jpg\"><strong>ACTIVE USER LISTS:</strong></td></tr>";
    for($v=0;$v<=$m;$v++)
	{
	echo "$contact_list";
	}
	
	echo "</table></center>";
	
	//echo "<br><div align=\"center\"><input name=\"deleteall\" type=\"submit\" value=\"DELETE CHECKED\"></form></div>";
		
	}
		   
		   
		   
		    
		   
		if(isset($_GET['userid'])) 
		   {
		   echo "<script type=\"text/javascript\">show_confirm();</script>"; 
		   }
		  if(isset($_GET['deleteall']))
		     {
			 $countz;
			 for($countz=1;$countz<=$number;$countz++)
			    {
				$user = "root";
				$pass = "";
	
				$connection = mysql_connect("localhost","$user","$pass")
				or die(mysql_error());

				$db = mysql_select_db($db_name, $connection) or die(mysql_error());
	
				$sql = "DELETE FROM $table_name WHERE userid = '$_POST[$countz]'";

				$result = mysql_query($sql, $connection) or die(mysql_error());
				
				}
			 }
	?>
         </br>
      <a href='adduser.php?userid=$userid'><img align="absmiddle"src="images/employee.png" title="Add User" width="50" height="50"></div>
</div>
<!-- content ends -->
<!-- footer begins -->
<div id="footer">
   <a href="http://validator.w3.org/check?uri=referer">Copyrights © 2012</a> | <a href="http://guinobatan.gov.ph/index.php/guinobatan/index">Municipality of Guinobatan</a>. | All rights reserved. 
      </p></div>
<!-- footer ends -->
</div>
</div>
</body>
</html>